package com.demo.biz.user.controller;

import com.demo.base.response.Result;
import com.demo.biz.user.model.req.UserLoginReq;
import com.demo.biz.user.model.resp.UserLoginResp;
import com.demo.biz.user.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * @author 曳戈泰尔
 * @version 1.0
 * @description 用户类
 * @date 2023/3/14 3:34 PM
 */
@RestController
@RequestMapping(value = "/user")
@Api(tags = "用户模块")
public class UserController {

    /** 注入用户服务层 */
    private final UserService userService;

    @Autowired
    public UserController(UserService userService) {
        this.userService = userService;
    }

    @PostMapping(value = "/login")
    @ApiOperation(value = "用户登录", notes = "用户登录-描述信息")
    public Result<UserLoginResp> userLogin(@Valid @RequestBody UserLoginReq userLoginReq) {
        return Result.success(userService.userLogin(userLoginReq));
    }
}
